from django.http import JsonResponse
from django.middleware.common import MiddlewareMixin
class ExceptionMiddleware(MiddlewareMixin):
    def process_exception(self, request, exception):
        print("异常是",exception)
        return JsonResponse ({'msg': '请求出现异常!'+str(exception), 'code': 500})